﻿// -----------------------------------------------------------------------
// <copyright file="HrManager.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace SoftServe.HrManager
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using SoftServe.HrManager.Abstractions;
    using SoftServe.HrManager.Models;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class HrManager
    {
        public string Name { get; set; }
        CandidateSkillChecker mCandidateSkillChecker = new CandidateSkillChecker();
        public Dictionary<eSkillName, DeveloperFactory> mSkillsForFactory { get; set; }

        public List<eSkillName> BackEndSkills { get; set; }
        public List<eSkillName> FrontEndSkills { get; set; }


        public HrManager()
        {
            mSkillsForFactory = new Dictionary<eSkillName, DeveloperFactory>();
            mSkillsForFactory.Add(eSkillName.JSP, new JavaDevFactory());
            mSkillsForFactory.Add(eSkillName.MVC3, new CSharpDevFactory());
            BackEndSkills = new List<eSkillName>()
            {
                eSkillName.Patterns
            };
            FrontEndSkills = new List<eSkillName>()
            {
                eSkillName.Ajax,
                eSkillName.HTML
            };
        }

        public IEnumerable<FrontEndDeveloperBase> SelectFrontEndCandidates(IEnumerable<Candidate> list)
        {
            foreach (var candidate in list)
            {
                foreach (var item in mSkillsForFactory.Keys)
                {
                    if (mCandidateSkillChecker.AssertSkill(candidate as ISkillEnumerator, item))
                        yield return mSkillsForFactory[item].CreateFrontEndDeveloper(candidate.Name);
                }
            }
        }

        public IEnumerable<BackEndDeveloperBase> SelectBackEndCandidates(IEnumerable<Candidate> list)
        {
            foreach (var candidate in list)
            {
                foreach (var item in mSkillsForFactory.Keys)
                {
                    if (mCandidateSkillChecker.AssertSkill(candidate as ISkillEnumerator, item))
                        yield return mSkillsForFactory[item].CreateBackEndDeveloper(candidate.Name);
                }
            }
        }
    }
}
